package com.xiu.travel.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * SwaggerConfig
 *
 * @author yingyingying
 * @date 2023/4/3 14:32
 */
@Configuration
public class SwaggerConfig
{
    private static final Contact DEFAULT_CONTACT = new Contact().name("qianlNya")
            .url("www.xiu.com")
            .email("2502203399@qq.com");


    @Bean
    public OpenAPI springShopOpenAPI()
    {
        return new OpenAPI()
                .info(new Info().title("xiu-travel-open的接口文档").contact(DEFAULT_CONTACT)
                              .description("xiu-travel-open接口文档")
                              .version("1.0.0")
                              .license(new License().name("Apache 2.0").url("http://springdoc.org")))
                .externalDocs(new ExternalDocumentation()
                                      .description("qianlanyuyun")
                                      .url("http://xiu.com:9000"));
    }

    @Bean
    public GroupedOpenApi httpApi()
    {
        return GroupedOpenApi.builder()
                .group("管理接口")
                .pathsToMatch("/admin/api/**")
                .build();
    }
    @Bean
    public GroupedOpenApi httpApi5()
    {
        return GroupedOpenApi.builder()
                .group("门户管理接口")
                .pathsToMatch("/portal/admin/**")
                .build();
    }

    @Bean
    public GroupedOpenApi httpApi2()
    {
        return GroupedOpenApi.builder()
                .group("公开接口")
                .pathsToMatch("/admin/open/**")
                .build();
    }
    
    @Bean
    public GroupedOpenApi httpApi3()
    {
        return GroupedOpenApi.builder()
                .group("门户接口")
                .pathsToMatch("/portal/api/**")
                .build();
    }
    
    @Bean
    public GroupedOpenApi httpApi4()
    {
        return GroupedOpenApi.builder()
                .group("门户公开接口")
                .pathsToMatch("/portal/open/**")
                .build();
    }


}
